home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 4 / FM Towns Free Software Collection 4 - Disc 1.iso / msdos / chgpal / chgpal.c next >
Text File  |  1991-10-18  |  8KB  |  191 lines

  1. /*****************************************************************************/
  2. /*         FM-Towns 用 MS-DOS画面テキスト文字色変更プログラム                */
  3. /*                         Copyright(C) June 19th,1991 by T.J.SHIN           */
  4. /*                         Special Thanks for ま~くん師匠                   */
  5. /*****************************************************************************/
  6. /*
  7.   履歴
  8. ------------------------------------------------------------------------------
  9.   1991.06.19 T.J.SHIN 作成
  10. ------------------------------------------------------------------------------
  11. *******************************************************************************
  12.   編集画面レイアウト
  13. *******************************************************************************
  14.  
  15.                    ******************************************
  16.                    *      MS-DOS文字色変更プログラム V1.0   *
  17.                    *             Copyrigt(C) June 19,1991   *
  18.                    *             Made       by T.J.SHIN     *
  19.                    *             Given Idia by ありおん     *
  20.                    *             Assist     by ま~くん師匠 *
  21.                    ******************************************
  22.  
  23.                               文字色用色識別番号
  24.  
  25.                         低輝度用               高輝度用
  26.                       1 2 3 4 5 6 7          9101112131415
  27.                      ■■■■■■■         ■■■■■■■
  28.  
  29.                    変更する色識別番号      赤色  緑色  青色
  30.                            __    ■         __    __    __
  31.  
  32.  
  33. *******************************************************************************
  34. */
  35. #include <stdio.h>
  36. #include <fif.h>
  37.  
  38. /* パレット色変更ルーチン */
  39. extern void chg_pal( ) ;
  40.  
  41. #define ESC    0x1b
  42. #define CUR_R  0x1c
  43. #define CUR_L  0x1d
  44. #define CUR_U  0x1e
  45. #define CUR_D  0x1f
  46. #define M_get  0x0ff00
  47. #define M_code 0x0ff
  48.  
  49. void main()
  50. {
  51.    int f_end=0 ;               /* 処理終了フラグ */
  52.    int ret,lpc ;               /* 戻り値,loopカウント用 */
  53.    int mode ;                  /* 処理モード(0:読み取り,1:書き込み) */
  54.    int n_c[4] ;                /* パレット番号及び各色(赤,緑,青)の割当数 */
  55.    int lc_set ;                /* 設定する項目の位置 */
  56.    unsigned int  moji,encode ;
  57.    static char *tit01="******************************************" ;
  58.    static char *tit02="*      MS-DOS文字色変更プログラム V1.0   *" ;
  59.    static char *tit03="*             Copyrigt(C) June 20,1991   *" ;
  60.    static char *tit04="*             Made       by T.J.SHIN     *" ;
  61.    static char *tit05="*             Given Idia by ありおん     *" ;
  62.    static char *tit06="*             Assist     by ま~くん師匠 *" ;
  63.    static char *tit07="******************************************" ;
  64.    static char *tit1[16]={ "", /* 低輝度色識別番号0:変更不可 */
  65.                            "", /* 低輝度色識別番号1          */
  66.                            "", /* 低輝度色識別番号2          */
  67.                            "", /* 低輝度色識別番号3          */
  68.                            "", /* 低輝度色識別番号4          */
  69.                            "", /* 低輝度色識別番号5          */
  70.                            "", /* 低輝度色識別番号6          */
  71.                            "", /* 低輝度色識別番号7          */
  72.                            "", /* 高輝度色識別番号0:変更不可 */
  73.                            "", /* 高輝度色識別番号1          */
  74.                            "", /* 高輝度色識別番号2          */
  75.                            "", /* 高輝度色識別番号3          */
  76.                            "", /* 高輝度色識別番号4          */
  77.                            "", /* 高輝度色識別番号5          */
  78.                            "", /* 高輝度色識別番号6          */
  79.                            ""  /* 高輝度色識別番号7          */
  80.                      } ;
  81.    static char *tit2="文字色用",*tit3="色識別番号" ;
  82.    static char *tit4="低輝度用               高輝度用" ;
  83.    static char *tit6=" 1 2 3 4 5 6 7          9101112131415";
  84.    static char *tit8="変更する",*tit9="赤色 緑色 青色" ;
  85.    static int co_x[4] = { 28 , 45 , 51 , 57 } ;
  86.  
  87.    /* 初期画面出力 */
  88.  
  89.    VDB_init() ; /* 画面の初期化     */
  90.  
  91.    VDB_setposcus(20, 1) ;  VDB_outstr(42,tit01) ;
  92.    VDB_setposcus(20, 2) ;  VDB_outstr(42,tit02) ;
  93.    VDB_setposcus(20, 3) ;  VDB_outstr(42,tit03) ;
  94.    VDB_setposcus(20, 4) ;  VDB_outstr(42,tit04) ;
  95.    VDB_setposcus(20, 5) ;  VDB_outstr(42,tit05) ;
  96.    VDB_setposcus(20, 6) ;  VDB_outstr(42,tit06) ;
  97.    VDB_setposcus(20, 7) ;  VDB_outstr(42,tit07) ;
  98.  
  99.    VDB_setposcus(31, 9) ;  VDB_outstr(8,tit2) ;
  100.    VDB_setposcus(39, 9) ;  VDB_outstr(10,tit3) ;
  101.    VDB_setposcus(25,11) ;  VDB_outstr(31,tit4) ;
  102.    VDB_setposcus(22,12) ;  VDB_outstr(37,tit6) ;
  103.    VDB_setposcus(22,13) ;  for (lpc=1;lpc< 8;lpc++) VDB_outstr(13,tit1[lpc]) ;
  104.    VDB_setposcus(45,13) ;  for (lpc=9;lpc<16;lpc++) VDB_outstr(13,tit1[lpc]) ;
  105.  
  106.    VDB_setposcus(20,16) ;  VDB_outstr(8,tit8) ;
  107.    VDB_setposcus(28,16) ;  VDB_outstr(10,tit3) ;
  108.    VDB_setposcus(44,16) ;  VDB_outstr(16,tit9) ;
  109.  
  110.    lc_set = 0 ; n_c[0]=1 ;
  111.    VDB_setposcus(co_x[0],17) ;
  112.    printf("%2d",n_c[0]) ;
  113.    VDB_setposcus(34,17) ; VDB_outstr(13,tit1[(n_c[lc_set])]) ;
  114.    chg_pal(0 , n_c[0], &n_c[1], &n_c[2], &n_c[3]) ;
  115.    VDB_setposcus(co_x[1],17) ;
  116.    printf("%2d    %2d    %2d", n_c[1],n_c[2],n_c[3]);
  117.  
  118.    VDB_setposcus(co_x[lc_set],17) ;
  119.  
  120.    /* 色識別番号の色変更メイン */
  121.    while ( f_end == 0 )
  122.    {
  123.        moji = KYB_read(1,&encode) ;
  124.        if ( (moji & M_get) != 0 ) continue ; /* キー入力無し */
  125.        moji = moji & M_code ;
  126.        switch(moji)
  127.        {
  128.            case ESC :     /* Program terminate */
  129.               f_end = 1 ;
  130.               break ;
  131.            case CUR_R :   /* Selecting changing part */
  132.               lc_set++;
  133.               if ( lc_set >= 3 ) lc_set = 3;
  134.               VDB_setposcus(co_x[lc_set],17) ;
  135.               break ;
  136.            case CUR_L :   /* Selecting changing part */
  137.               lc_set--;
  138.               if ( lc_set <= 0 ) lc_set = 0;
  139.               VDB_setposcus(co_x[lc_set],17) ;
  140.               break ;
  141.            case CUR_U :   /* Countupping  palette no. or color no. */
  142.               n_c[lc_set]++;
  143.               if ( lc_set == 0 )
  144.               {
  145.                   if ( n_c[lc_set] >= 15 ) n_c[lc_set] = 15;
  146.                   if ( n_c[lc_set] ==  8 ) n_c[lc_set] =  9;
  147.                   printf("%2d",n_c[lc_set]) ;
  148.                   VDB_setposcus(34,17) ; VDB_outstr(13,tit1[(n_c[lc_set])]) ;
  149.                   VDB_setposcus(co_x[lc_set],17) ;
  150.                   chg_pal(0 , n_c[0], &n_c[1], &n_c[2], &n_c[3]) ;
  151.                   VDB_setposcus(co_x[1],17) ;
  152.                   printf("%2d    %2d    %2d", n_c[1],n_c[2],n_c[3]);
  153.                   VDB_setposcus(co_x[lc_set],17) ;
  154.               }
  155.               else
  156.               {
  157.                   if ( n_c[lc_set] >= 15 ) n_c[lc_set] = 15;
  158.                   printf("%2d",n_c[lc_set]) ;
  159.                   VDB_setposcus(co_x[lc_set],17) ;
  160.                   chg_pal(1 , n_c[0], n_c[1], n_c[2], n_c[3]) ;
  161.               }
  162.               break ;
  163.            case CUR_D :   /* Countdowning palette no. or color no. */
  164.               n_c[lc_set]--;
  165.               if ( lc_set == 0 )
  166.               {
  167.                   if ( n_c[lc_set] <= 1 ) n_c[lc_set] = 1;
  168.                   if ( n_c[lc_set] == 8 ) n_c[lc_set] = 7;
  169.                   printf("%2d",n_c[lc_set]) ;
  170.                   VDB_setposcus(34,17) ; VDB_outstr(13,tit1[(n_c[lc_set])]) ;
  171.                   VDB_setposcus(co_x[lc_set],17) ;
  172.                   chg_pal(0 , n_c[0], &n_c[1], &n_c[2], &n_c[3]) ;
  173.                   VDB_setposcus(co_x[1],17) ;
  174.                   printf("%2d    %2d    %2d", n_c[1],n_c[2],n_c[3]);
  175.                   VDB_setposcus(co_x[lc_set],17) ;
  176.               }
  177.               else
  178.               {
  179.                   if ( n_c[lc_set] <= 0 ) n_c[lc_set] = 0;
  180.                   printf("%2d",n_c[lc_set]) ;
  181.                   VDB_setposcus(co_x[lc_set],17) ;
  182.                   chg_pal(1 , n_c[0], n_c[1], n_c[2], n_c[3]) ;
  183.               }
  184.               break ;
  185.        }
  186.  
  187.    }
  188.  
  189.    VDB_cls() ; /* 画面のクリア */
  190. }
  191.